//
//  Sun.m
//  SujetObserver
//
//  Created by Pierre DUCHENE on 25/01/10.
//  Copyright 2010 Pierre DUCHENE. All rights reserved.
//

#import "Sun.h"

@implementation Sun

@synthesize sensor;
@synthesize inProgress;
@synthesize temperature;

- (id)init
{
	if (self = [super init]) {
		sensor = nil;
		inProgress = NO;
		temperature = 0;
	}
	return self;
}

- (void)dealloc
{
	[(id)sensor release];
	sensor = nil;
	
	[super dealloc];
}

- (void)start
{
	NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
	
	inProgress = YES;
	while (self.isInProgress) {
		self.temperature++;
		[sensor setSensorValue:[NSNumber numberWithInt:temperature]];
		[NSThread sleepForTimeInterval:1.5];
	}
	
	[pool release];
	pool = nil;
}

- (void)stop
{
	inProgress = NO;
}

@end
